home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / calc / help / expression < prev    next >
Text File  |  1995-07-17  |  1KB  |  36 lines

  1. Expression sequences
  2.  
  3.     This is a sequence of statements, of which expression statements
  4.     are the commonest case.  Statements are separated with semicolons,
  5.     and the newline character generally ends the sequence.  If any
  6.     statement is an expression by itself, or is associated with an
  7.     'if' statement which is true, then two special things can happen.
  8.     If the sequence is executed at the top level of the calculator,
  9.     then the value of '.' is set to the value of the last expression.
  10.     Also, if an expression is a non-assignment, then the value of the
  11.     expression is automatically printed if its value is not NULL.
  12.     Some operations such as    pre-increment and plus-equals are also
  13.     treated as assignments.
  14.  
  15.     Examples of this are the following:
  16.  
  17.     expression        sets '.' to        prints
  18.     ----------        -----------        ------
  19.     3+4            7            7
  20.     2*4; 8+1; fact(3)    6            8, 9, and 6
  21.     x=3^2            9            -
  22.     if (3 < 2) 5; else 6    6            6
  23.     x++            old x            -
  24.     print fact(4)        -            24
  25.     null()            null()            -
  26.  
  27.     Variables can be defined at the beginning of an expression sequence.
  28.     This is most useful for local variables, as in the following example,
  29.     which sums the square roots of the first few numbers:
  30.  
  31.     local s, i; s = 0; for (i = 0; i < 10; i++) s += sqrt(i); s
  32.  
  33.     If a return statement is executed in an expression sequence, then
  34.     the result of the expression sequence is the returned value.  In
  35.     this case, '.' is set to the value, but nothing is printed.
  36.